package com.sanyou.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
 * @description: 时间工具类
 * @author: chase
 * @time: 2022/11/17 下午3:59
 */
public class TimeUtils {
    /**
     * @description: 判断传入日期是否是今天
     * @param dateIn
     * @return: java.lang.Boolean
     * @author: chase
     * @time: 2022/11/17 下午3:58
     */
    public static Boolean isToday(Date dateIn){
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String nowFormat = dateFormat.format(now);
        System.out.println(nowFormat);
        String dateinformat = dateFormat.format(dateIn);
        System.out.println(dateinformat);
        return nowFormat.equals(dateinformat);
    }
    /**
     * @description:  判断传入两日期是否是同一天
     * @return: java.lang.Boolean
     * @author: chase
     * @time: 2022/11/17 下午3:58
     */
    public static Boolean isSameDay(Date date1,Date date2){
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTime(date1);
        cal2.setTime(date2);

        return cal1.get(Calendar.YEAR)==cal2.get(Calendar.YEAR)&&cal1.get(Calendar.DAY_OF_YEAR)==cal2.get(Calendar.DAY_OF_YEAR);
    }


}
